home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbaux.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-03-07  |  7.5 KB  |  210 lines

  1. (*===========================================================================*)
  2. (* Auxiliary task                                                            *)
  3. (*                                                                           *)
  4. (*   Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen.  All       *)
  5. (*   rights reserved.                                                        *)
  6. (*                                                                           *)
  7. (*===========================================================================*)
  8.  
  9. UNIT BBAUX;
  10.  
  11. INTERFACE
  12.  
  13. PROCEDURE aux_task_start;
  14.  
  15. VAR
  16.   time_mon  : LONGINT;
  17.   found_mon : BOOLEAN;
  18.  
  19. IMPLEMENTATION
  20.  
  21. USES
  22.   bbauxm,
  23.   bbbcst,
  24.   bbdummy,
  25.   bblog,
  26.   bblstr,
  27.   bbmdata,
  28.   bbmess,
  29.   bbmf,
  30.   bbmisc,
  31.   bbmisci,
  32.   bbmisc4,
  33.   bbmon,
  34.   bbrdata,
  35.   bbsdata,
  36.   bbsess,
  37.   bbsrt,
  38.   bbstr,
  39.   bbtask,
  40.   bbtime,
  41.   bbuser,
  42.   bbwin;
  43.  
  44. (*===========================================================================*)
  45. (* Never ending loop that runs the aux process                               *)
  46. (*===========================================================================*)
  47.  
  48. PROCEDURE aux_task_start;
  49.  
  50.   VAR
  51.     clean_count : BYTE;
  52.     delay_count : BYTE;
  53.     do_speed    : BOOLEAN;
  54.     master_mon  : BOOLEAN;
  55.     modem_port  : BOOLEAN;
  56.     t_str       : STRING[4];
  57.     this_port   : port_block_ptr;
  58.     time_bcst   : LONGINT;
  59.  
  60.   {$I 8250CON.PAS}
  61.   {$I BBAUXI.PAS}                (* Check inactive                           *)
  62.   {$I BBAUXR.PAS}                (* Telephone ring                           *)
  63.  
  64.   BEGIN;
  65.  
  66.     (*-----------------------------------------------------------------------*)
  67.     (* Allow master task to regain control to build my control block         *)
  68.     (*-----------------------------------------------------------------------*)
  69.  
  70.     task_switch;
  71.  
  72.     (*-----------------------------------------------------------------------*)
  73.     (* Set up master                                                         *)
  74.     (*-----------------------------------------------------------------------*)
  75.  
  76.     master_mon := NOT found_mon;
  77.     found_mon  := TRUE;
  78.  
  79.     (*-----------------------------------------------------------------------*)
  80.     (* Set up some switches                                                  *)
  81.     (*-----------------------------------------------------------------------*)
  82.  
  83.     modem_port := (active_port^.port_type = port_modem)
  84.                                  OR (active_port^.port_type = port_null_modem);
  85.  
  86.     clean_count := 1;
  87.  
  88.     (*-----------------------------------------------------------------------*)
  89.     (* Prep broadcast time                                                   *)
  90.     (*-----------------------------------------------------------------------*)
  91.  
  92.     IF (NOT modem_port)
  93.            AND (active_port^.port_bcst OR (active_port^.rel_port <> NIL)) THEN
  94.       time_bcst := 5
  95.     ELSE
  96.       time_bcst := max_time;
  97.  
  98.     (*-----------------------------------------------------------------------*)
  99.     (* Get ready for loop                                                    *)
  100.     (*-----------------------------------------------------------------------*)
  101.  
  102.     delay_count := 1;
  103.     do_speed    := FALSE;
  104.  
  105.     (*-----------------------------------------------------------------------*)
  106.     (* Main loop                                                             *)
  107.     (*-----------------------------------------------------------------------*)
  108.  
  109.     WHILE TRUE DO
  110.       WITH active_tcb^ DO
  111.         BEGIN;
  112.  
  113.           (*-----------------------------------------------------------------*)
  114.           (* Force a switch.                                                 *)
  115.           (*-----------------------------------------------------------------*)
  116.  
  117.           task_switch;
  118.  
  119.           (*-----------------------------------------------------------------*)
  120.           (* Monitor the port.  Don't do modems, subports or when operator   *)
  121.           (* is connected to monitor port                                    *)
  122.           (*-----------------------------------------------------------------*)
  123.  
  124.           IF (NOT modem_port)
  125.                              AND (NOT active_port^.port_sub_port)
  126.                              AND (active_port^.connected^[0] = NIL) THEN
  127.             BEGIN;
  128.  
  129.               (*-------------------------------------------------------------*)
  130.               (* Poll the port.  Skip monitor if no data                     *)
  131.               (*-------------------------------------------------------------*)
  132.  
  133.               send_recv_tnc(2);
  134.  
  135.               IF NOT active_tcb^.tnc_null THEN
  136.                 monitor_all;
  137.  
  138.             END;
  139.  
  140.           (*-----------------------------------------------------------------*)
  141.           (* If it has been a while then do the waiting things               *)
  142.           (*-----------------------------------------------------------------*)
  143.  
  144.           IF delay_count > 15 THEN
  145.             BEGIN;
  146.  
  147.               (*-------------------------------------------------------------*)
  148.               (* Reset the delay                                             *)
  149.               (*-------------------------------------------------------------*)
  150.  
  151.               delay_count := 0;
  152.  
  153.               (*-------------------------------------------------------------*)
  154.               (* Do a broadcast                                              *)
  155.               (*-------------------------------------------------------------*)
  156.  
  157.               IF (time_bcst < up_time) THEN
  158.                 BEGIN;
  159.  
  160.                   (*---------------------------------------------------------*)
  161.                   (* Send the broadcast                                      *)
  162.                   (*---------------------------------------------------------*)
  163.  
  164.                   send_any_broadcasts;
  165.  
  166.                   (*---------------------------------------------------------*)
  167.                   (* Schedule next broadcast                                 *)
  168.                   (*---------------------------------------------------------*)
  169.  
  170.                   time_bcst := up_time_from_now(60 * opt_block.bcst_interval);
  171.  
  172.                 END;
  173.  
  174.               (*-------------------------------------------------------------*)
  175.               (* Check the inactive channels to see if they want anything    *)
  176.               (*-------------------------------------------------------------*)
  177.  
  178.               IF NOT modem_port THEN
  179.                 check_inact
  180.               ELSE
  181.                 check_ring;
  182.  
  183.               (*-------------------------------------------------------------*)
  184.               (* Sync the log                                                *)
  185.               (*-------------------------------------------------------------*)
  186.  
  187.               IF master_mon AND (up_time > log_time) THEN
  188.                 log_sync;
  189.  
  190.               (*-------------------------------------------------------------*)
  191.               (* Sync the monitor                                            *)
  192.               (*-------------------------------------------------------------*)
  193.  
  194.               IF master_mon AND (time_mon < up_time) THEN
  195.                 monitor_up;
  196.  
  197.             END; (*----- End Only-once-in-a-while Actions -------------------*)
  198.  
  199.           INC(delay_count);
  200.  
  201.       END; (*----- End never-ending loop ------------------------------------*)
  202.  
  203.   END;
  204.  
  205. BEGIN;
  206.  
  207.   found_mon  := FALSE;
  208.  
  209. END.
  210.